<template>
  <dtDialog
    title="终审通过"
    :visible.sync="visible"
    :is-loading="loading"
    @closeDialog="orgResetTemp()"
    @comfirmBtn="onSubmit()"
  >
    <DtForm
      :form-opts="config"
      :width-size="1"
      :ref-obj.sync="config.ref"
    />
  </dtDialog>
</template>
<script>
import { stopProcessMaintain } from '@/framework/api/processMaintain/processMaintain'

export default {
  data() {
    return {
      loading: false,
      visible: false,
      config: {
        ref: null,
        labelWidth: '120px',
        formData: {
          instanceId: '',
          opinion: ''
        },
        labelPosition: 'right',
        columns: [
          {
            label: '终审意见',
            prop: 'opinion',
            type: 'textarea',
            component: 'el-input',
            maxlength: 100
          }
        ],
        rules: {
          opinion: [
            {
              required: true,
              message: '请输入终审意见',
              trigger: 'blur'
            }
          ]
        }
      }
    }
  },
  methods: {
    // 关闭弹窗
    orgResetTemp() {
      this.config.formData = {
        instanceId: '',
        opinion: ''
      }
      this.config.ref?.resetFields()
    },
    // 打开新增弹窗
    openDialog(row) {
      this.visible = true
      this.config.formData.instanceId = row.instanceId
    },
    // 创建请求
    async onSubmit() {
      this.config.ref.validate((valid) => {
        if (valid) {
          this.loading = true
          stopProcessMaintain(this.config.formData).then(() => {
            this.$parent.getList()
            this.$dtModal.msgSuccess('终止成功')
            this.visible = false
            this.loading = false
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>
  <style scoped lang="scss">
  ::v-deep .el-cascader {
    width: 100%;
  }
  </style>

